package com.kanasco.vision.controller;

import java.sql.SQLException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.view.RedirectView;

import com.kanasco.vision.service.ISales;

import bb.access.po.Term;

public class SaveTermController extends SimpleFormController{
	ISales salesServices;

	public void setSalesServices(ISales salesServices) {
		this.salesServices = salesServices;
	}
	
	public ISales getSalesServices() {
		return salesServices;
	}
	public SaveTermController() 
	{
	setCommandClass(Term.class);
	setCommandName("term");
	}
	protected ModelAndView onSubmit(HttpServletRequest req,HttpServletResponse res,Object command,BindException exception) throws SQLException
  	{
		System.out.println("Onsubmit from SaveTerm Controller");
		Term term=(Term)command;
		term.getTerm();
		term.getDays();
		term.getComments();
		salesServices.Save(term);
		return new ModelAndView("SaveTerm","term",term);
	/*	return new ModelAndView(new RedirectView("saveTerm.htm"));*/
  	}
 
}
